﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>หน้ารวมโรงควบคุม</title>
</head>
<style>
#header{
	height: 32px;
	margin-right: 20px;
	margin-left: 2px;
}

#header_titile{
	float: left;
}

#main{
	width:800px;
	margin: 0 auto 0 auto;
	border: 1px solid #E5E5E5;
	padding: 26px 24px 46px;
}

#user_info{
	float: right;
	font-size: 14px;
	/*line-height: 26px;*/
	height: 25px;
	position: relative;
/*	z-index: 49; */
	border-style: solid;
	border-width: 0;
	/* margin-top: 3px; */
	padding: 0 2px 0 6px;
	display:block;
}

body{
	font-family:tahoma;
	font-size:14px;	
}
</style>
<script type="text/javascript">
checked=false;
function checkAll(a_form)
{
    var aa = document.getElementById(a_form);
    if (checked == false)
      checked = true
    else
      checked = false
    for (var i =0; i < aa.elements.length; ++i) 
    {
      aa.elements[i].checked = checked;
    }
}
</script>

<body>
<div id="main">
<div id="header" >
	<a href="<?php echo site_url('welcome') ?>">หน้าหลัก</a> -- แก้ไขฐานข้อมูลโรงควบคุม
<div id="user_info">สวัสดีคุณผู้ใช้ <?php echo $_SESSION['username']; ?><?php echo " (".$_SESSION['user_level'].")"; ?> <a href="<?php echo site_url('webadmin/logout') ?>">ออกจากระบบ</a></div>
</div>

<br />
<p>
<?php 
  $form_id = array("id" => "myform");
  echo form_open("plant/delete_plant", $form_id); 

  $bool = ($_SESSION['user_level'] != "reader");
  if ($bool == TRUE)
  {
      echo "<input type='submit' id='delete' value='ลบ' onclick=\"javascript:return confirm('delete?')\" /> ";
      echo "<a href=".site_url('plant/add_plant').">เพิ่มโรงควบคุม</a>";
  }
?>
<p/>
<table border="1" cellspacing="0">
  <tr >
    <th width="20">
    	<input type="checkbox" name='checkall' onclick="checkAll('myform')" />
    </th>
    <th width="200">โรงควบคุม</th>
    <th width="200">การกระทำ</th>
  </tr>
  <?php 
  	if (count($rs) == 0)
  	{
  		echo "<tr><td>NA</td><td>no data</td><td>no data</td>";
  	}
  	else
  	{
  		$no = 1;
  		foreach ($rs as $row) {
  			echo "<tr>";
  			echo "<td><input type='checkbox' name='mycheckbox[]' value='".$row->pid."' /></td>";
  			echo "<td>".$row->name."</td>";
        	echo "<td>";
        	echo "<a href=".site_url('plant/plant_edit')."/".$row->pid.">edit</a> ";
          if ($bool == TRUE)
          {
        	   echo "<a href=".site_url('plant/rename_plant')."/".$row->pid.">rename</a>";
          }
        	echo "</td>";
  			echo "<tr>";
  			++$no;
  		}
  	}
  ?>

</table>
<p>
<?php
  if ($bool == TRUE)
  {
      echo "<input type='submit' id='delete' value='ลบ' onclick=\"javascript:return confirm('delete?')\" /> ";
      echo "<a href=".site_url('plant/add_plant').">เพิ่มโรงควบคุม</a>";
  }
 ?>
<?php echo form_close(); ?>
</p>
</div>
</body>
</html>
